{
 "cells": [
  {
   "cell_type": "raw",
   "metadata": {},
   "source": [
    "1. 验证码生成\n",
    "1.1 内容描述\n",
    "使用captcha模块根据给定的文本集合，随机抽取出指定个数的文本组成一个验证码字符串，并根据字符串生成验证码图片，构建captcha_func.py文件。\n",
    "1.2 代码编写"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 6,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "image/png": "iVBORw0KGgoAAAANSUhEUgAAAXAAAACfCAYAAADgfILcAAAABHNCSVQICAgIfAhkiAAAAAlwSFlzAAALEgAACxIB0t1+/AAAADh0RVh0U29mdHdhcmUAbWF0cGxvdGxpYiB2ZXJzaW9uMy4xLjMsIGh0dHA6Ly9tYXRwbG90bGliLm9yZy+AADFEAAAgAElEQVR4nO19aXRkZ3nm81WVqkqlfWm11Gqpu91uL+02XmKCjQkxxhsOyzADGQgnYyZOmExIICRM2E4yW5IJBwIkJyEDExMzE8ISE4jDOBjGhkCAGNtgvLS33hfte0mqkqpK3/x43+feW7elVmmrRf0953Rf1d3qu+/97q3n3Y21Fg4ODg4OtYdIpQfg4ODg4LA+uBe4g4ODQ43CvcAdHBwcahTuBe7g4OBQo3AvcAcHB4cahXuBOzg4ONQoNvQCN8bcYYx53hhzxBjz/s0alIODg4PD6jDrjQM3xkQBvADgVgBnADwK4K3W2sObNzwHBwcHh5UQ28CxPw3giLX2GAAYY74A4A0AVnyBd3Z22P69/Rv4ytrFCy+OLbv+kgOdZR6Jg4NDreHHjz8xZq3dEV6/kRd4L4DTgc9nALwsvJMx5h0A3gEAff278d0fPryBr6xd3H7nvcuuf/CBt5d1HA4ODrWHxmj7yeXWb+QFbpZZd449xlr7aQCfBoBrr7umJHtNLlfw/j51Qphrfkk+z8/nAACFgiyTySgAYNeudgBAKpUAACTicmkmstwwtx4zMwsAgL/8zGMAgCsOdhVtv/uXrivar7k5UcbR1SYoKwA4fWYaAPDgN14EANx+2wEAQN/uFgBOng4XBjbixDwDoC/weTeAgY0Nx8HB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gWgDfpbtUwziEAp40xl+qqVwM4jCqTJ8R0cr0xJqVzgOOsKnkGsJL87gfw7zR64noA0zS1VALGmDsAvA/A662184FN9wN4izEmYYzZB3ES/rASY7TWPmWt7bLW7tXn6QyAa3XuVpU8V0UZnQh3QrzSRwF8qNLG/8C4XgFRkZ4E8IT+uxNiX34IwIu6bK/0WANjvgnA1/TviyAPwhEAfwsgUQXjuxrAYyrTrwJoq0Z5AvivAJ4D8DSA/wMgUQ3yBPB5iF0+B3m53L2S/CAq/5/rc/UUJKqmkuM8ArEh81n6n4H9P6TjfB7Aayo5ztD2E/CdmBWT53r+uVR6BwcHhxqFy8R0cHBwqFG4F7iDg4NDjcK9wB0cHBxqFO4F7uDg4FCjcC9wBwcHhxqFe4E7ODg41CjcC9zBwcGhRvH/AcZM0OKLGAFEAAAAAElFTkSuQmCC\n",
      "text/plain": [
       "<Figure size 432x288 with 1 Axes>"
      ]
     },
     "metadata": {
      "needs_background": "light"
     },
     "output_type": "display_data"
    }
   ],
   "source": [
    "from captcha.image import ImageCaptcha #pip install captcha\n",
    "import numpy as np\n",
    "import matplotlib.pyplot as plt\n",
    "from PIL import Image #pillow\n",
    "#c 操作图片，一般使用opencv\n",
    "#python 操作图片，opencv、pillow\n",
    "import random\n",
    "\n",
    "number = ['0', '1', '2', '3', '4', '5', '6', '7', '8', '9']\n",
    "alphabet = ['a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's', 't', 'u',\n",
    "            'v', 'w', 'x', 'y', 'z']\n",
    "ALPHABET = ['A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M', 'N', 'O', 'P', 'Q', 'R', 'S', 'T', 'U',\n",
    "            'V', 'W', 'X', 'Y', 'Z']\n",
    "MAX_CAPTCHA=4\n",
    "IMAGE_HEIGHT = 60\n",
    "IMAGE_WIDTH = 160\n",
    "# 文本转向量\n",
    "#char_set = number + alphabet + ALPHABET + ['_']  # 如果验证码长度小于4, '_'用来补齐\n",
    "char_set=number\n",
    "CHAR_SET_LEN = len(char_set)\n",
    "#char_set 从上面生成 随机生成四位\n",
    "def random_captcha_text(char_set=char_set, captcha_size=MAX_CAPTCHA):#captcha_size是验证码有多少位\n",
    "    captcha_text = []\n",
    "    for i in range(captcha_size):\n",
    "        c = random.choice(char_set)#随机的取一个值\n",
    "        captcha_text.append(c)\n",
    "    return captcha_text\n",
    "\n",
    "#生成验证码\n",
    "def gen_captcha_text_and_image():\n",
    "    image = ImageCaptcha()\n",
    "\n",
    "    captcha_text = random_captcha_text()\n",
    "    captcha_text = ''.join(captcha_text)\n",
    "    #把字符生成图像验证码\n",
    "    captcha = image.generate(captcha_text)\n",
    "    # image.write(captcha_text, captcha_text + '.jpg')\n",
    "\n",
    "    # 把图片转换为数组形式\n",
    "    captcha_image = Image.open(captcha)\n",
    "    captcha_image = np.array(captcha_image)\n",
    "\n",
    "    #得到label和图像\n",
    "    return captcha_text, captcha_image\n",
    "\n",
    "text, image = gen_captcha_text_and_image()\n",
    "f= plt.figure()\n",
    "ax = f.add_subplot(111)\n",
    "ax.text(0.1, 0.9, text, ha='center', va='center', transform=ax.transAxes)\n",
    "plt.imshow(image)\n",
    "plt.show()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": []
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.7.0"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 4
}
